<?php
$environment_flag = '*** current env:UNKNOWN ***';
if (defined('ENVIRONMENT')){
	switch (ENVIRONMENT){
		case 'development':$environment_flag = '*** current env:DEVELOPMENT ***';break;
		case 'testing':$environment_flag = '*** current env:TESTING ***';break;
		case 'production':$environment_flag = '';break;
	}
}
?>
var viewport = new Ext.Viewport({
	layout:'border',
	items: [{
		xtype:'panel',
		region:'center',
		layout:'border',
		border:false,
		items:[
			new ZM.NavBar({
				childs: <?php echo $menu['mnu_layout']?>,
				info:'<?php echo $environment_flag?>&nbsp;&nbsp;您好!&nbsp;<?php echo $username?>,&nbsp;欢迎来到<?php echo PROJECT_ADMIN_NAME ?> &nbsp;&nbsp;<a href="#" id="resetPassword" title="Reset Password">修改密码</a>&nbsp;|&nbsp;<a href="'+list.baseUrl+'login/logout">退出</a>&nbsp;'
			}),
			list.leftNav,
			{
				xtype:'mainpanel',
				title: document.title,
				layout:(function(){return (typeof(list.detail)!=='undefined')?'border':'fit';})(),
				items:(function(){return (typeof(list.detail)!=='undefined')?[list.grid,list.detail]:list.grid;})()
			}]
	}]
});

document.getElementById('resetPassword').onclick =  function(){
	var frm = new ZM.FormPanel({
		url:list.baseUrl + 'app/changeUserPassword',
		items:[{
			fieldLabel:'新密码',
			name:'user_password',
			inputType:'password',
			id:'password',
			minLength:5,
			allowBlank:false
		},{
			fieldLabel:'新密码确认',
			name:'password_confirm',
			vtype:'password',
			initialPassField:'password',
			inputType:'password',
			minLength:5,
			allowBlank:false
		}],
		success:function(r){
			Ext.Msg.alert('操作成功', r.detail, location.href=list.baseUrl +'login');
		}
	});
	var win = new ZM.PopUp({
		title:'修改密码',
		type:'s',
		items:frm
	}).show();
};